#include <iostream>
#include <pthread.h>
#include <mutex>

class Mutex
{
public:
    Mutex(pthread_mutex_t *mtx):_mtx(mtx){}

    void Lock()
    {
        pthread_mutex_lock(_mtx);
    }

    void Unlock()
    {
        pthread_mutex_unlock(_mtx);
    }

private:
    pthread_mutex_t *_mtx;

};

//RAII
class lockGurad
{
public:
    lockGurad(pthread_mutex_t* mtx):_mtx(mtx)
    {
        _mtx.Lock();
    }

    ~lockGurad()
    {
        _mtx.Unlock();
    }

private:
   Mutex _mtx; 
};